<!DOCTYPE html>
<!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
-->
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: https://ssl.gstatic.com https://v3.alapi.cn https://www.alapi.cn 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' https://v3.alapi.cn https://www.alapi.cn; frame-src https://www.alapi.cn;">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="initial-scale=1, width=device-width, viewport-fit=cover">
        <meta name="color-scheme" content="light dark">
        <link rel="stylesheet" href="css/index.css">
        <title>震动功能</title>
        <style>
            .vibrate-container {
                max-width: 800px;
                margin: 0 auto;
                padding: 20px;
                background-color: #fff;
                min-height: calc(100vh - 100px);
            }
            .nav {
                background-color: #2c3e50;
                padding: 15px;
                text-align: center;
                margin-bottom: 20px;
            }
            .nav a {
                color: #fff;
                text-decoration: none;
                margin: 0 15px;
                font-size: 16px;
                padding: 8px 15px;
                border-radius: 4px;
                transition: background-color 0.3s;
                display: inline-block;
            }
            .nav a:hover, .nav a.active {
                background-color: #34495e;
            }
            .vibrate-header {
                text-align: center;
                margin-bottom: 30px;
                padding-bottom: 20px;
                border-bottom: 2px solid #3498db;
            }
            .vibrate-header h1 {
                color: #2c3e50;
                font-size: 2.5em;
                margin-bottom: 10px;
            }
            .vibrate-header p {
                color: #7f8c8d;
                font-size: 1.1em;
            }
            .btn {
                display: block;
                width: 100%;
                padding: 15px;
                margin: 0;
                border: none;
                border-radius: 6px;
                font-size: 16px;
                cursor: pointer;
                color: white;
                transition: opacity 0.2s, transform 0.2s;
            }
            .btn-short {
                background-color: #2196F3; /* 蓝色：短振动 */
            }
            .btn-long {
                background-color: #4CAF50; /* 绿色：长振动 */
            }
            .btn-stop {
                background-color: #F44336; /* 红色：停止振动 */
            }
            .btn:hover {
                opacity: 0.9;
                transform: translateY(-2px);
            }
            .note {
                color: #666;
                font-size: 14px;
                margin-top: 20px;
                padding: 10px;
                background-color: #f5f5f5;
                border-radius: 4px;
                text-align: left;
            }
            @media (max-width: 768px) {
                .vibrate-header h1 {
                    font-size: 2em;
                }
                .nav a {
                    display: block;
                    margin: 5px 0;
                }
            }
        </style>
    </head>
    <body>
        <div class="nav">
            <a href="index.html">首页</a>
            <a href="about.html">关于我们</a>
            <a href="poem.html">藏头诗</a>
            <a href="translate.html">翻译</a>
            <a href="express.html">快递查询</a>
            <a href="ip.html">IP查询</a>
            <a href="workday.html">工作日查询</a>
            <a href="network.html">网络状态</a>
            <a href="vibrate.html" class="active">震动功能</a>
            <a href="battery.html">电池状态</a>
        </div>
        <div class="vibrate-container">
            <div class="vibrate-header">
                <h1>设备振动插件示例</h1>
            </div>

            <div class="button-container" style="display: flex; flex-direction: column; gap: 12px; max-width: 600px; margin: 0 auto;">
                <button id="shortVibrate" class="btn btn-short">触发 500ms 短振动</button>
                <button id="longVibrate" class="btn btn-long">触发 2000ms 长振动</button>
                <button id="stopVibrate" class="btn btn-stop">停止当前振动</button>
            </div>

            <div id="toast" style="display: none; position: fixed; bottom: 50px; left: 50%; transform: translateX(-50%); background-color: #333; color: white; padding: 12px 24px; border-radius: 6px; z-index: 1000; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,0.3);"></div>

            <div class="note" style="max-width: 600px; margin: 30px auto 0;">
                <strong>注意事项：</strong><br>
                1. 振动功能需要在真实设备上测试，浏览器环境可能无法触发振动。<br>
                2. API: <code>navigator.vibrate(time)</code>，参数 time 为振动时长（毫秒）。<br>
                3. 传入 0 可停止当前振动。
            </div>
        </div>

        <script src="cordova.js"></script>
        <script src="js/utils.js"></script>
        <script src="js/vibrate.js"></script>
    </body>
</html>

